package com.gdk.ksoft.assembly.utils.system;

import android.content.Context;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.view.WindowManager;

/**
 * Created by Mrper on 2014/11/22.
 * 手机信息辅助类
 */
public class PhoneUtils {

    /**
     * 获取屏幕信息
     * @param context
     * @return
     */
    public static DisplayMetrics getScreenInfo(Context context){
        WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics dm = new DisplayMetrics();
        wm.getDefaultDisplay().getMetrics(dm);
        return dm;
    }

    /**
     * 获取手机IMEI标识(电信手机获取的是MEID)
     * @param context
     * @return
     */
    public static String getDeviceId(Context context)throws Exception{
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String IMEI = tm.getDeviceId();
        return IMEI;
        //       return "863551024103325";
    }

    /**
     * 获取手机号码
     * @param context
     * @return
     */
    public static String getPhoneNumber(Context context){
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return tm.getLine1Number();
    }

}
